import { Body, Controller, Get, Post } from '@nestjs/common';
import { AuthService } from './auth.service';
import { LoginDto } from 'src/users/dtos/login';
import { UserCreateDto } from 'src/users/dtos/signup';
import { $Enums } from '@prisma/client';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Post('/sign-up')
  async signUp(@Body() userDto: UserCreateDto) {
    const { accessToken } = await this.authService.signUp({
      ...userDto,
      role: $Enums.Role.USER,
    });

    return { accessToken };
  }

  @Post('/sign-in')
  async signIn(@Body() userDto: LoginDto) {
    const { accessToken } = await this.authService.signIn(userDto);

    return { accessToken };
  }
}
